package com.jic.market.impl.rest.allocation;


import java.util.EnumSet;

/**
 * @author : xuyongliang
 * @date : 2020/4/10
 * @description: ${description}
 * @modified By:
 * @version: V1.0
 */
public enum QueryPromotionForAllocationEnum {
    // normal 通用  groupon拼团   coupon优惠券  lottery抽奖
    SINGLELY(1, "queryPromotionForAllocationNormal"),
    FULL_NUM(2,"queryPromotionForAllocationNormal"),
    FULL(3, "queryPromotionForAllocationNormal"),
    SECKILL(4, "queryPromotionForAllocationNormal"),
    GIFT(5, "queryPromotionForAllocationNormal"),
    COMPLEX(6, "queryPromotionForAllocationNormal"),
    XOFFER(7, "queryPromotionForAllocationNormal"),
    increase(8, "queryPromotionForAllocationNormal"),
    SINGLE(9, "queryPromotionForAllocationNormal"),
    GROUPON(10, "queryPromotionForAllocationGroupon"),
    Coupon(11, "queryPromotionForAllocationCoupon"),
    RED(12, "queryPromotionForAllocationCoupon"),
    LOTTERY(13, "queryPromotionForAllocationLottery"),
    ;

    private Integer code;

    private String value;

    QueryPromotionForAllocationEnum(Integer code, String value) {
        this.code = code;
        this.value = value;
    }

    public static QueryPromotionForAllocationEnum getEnumByCode(Integer code){
        EnumSet<QueryPromotionForAllocationEnum> elements = EnumSet.allOf(QueryPromotionForAllocationEnum.class);
        for(QueryPromotionForAllocationEnum enumType : elements){
            if(enumType.getCode().equals(code)){
                return enumType;
            }
        }
        return null;
    }

    public static int getCodeByValue(String value) {
        for (QueryPromotionForAllocationEnum c : values()) {
            if (c.getValue().equals(value.trim())) {
                return c.code;
            }
        }
        return 0;
    }

    public static String getValue(Integer code) {
        return getEnumByCode(code).getValue();
    }

    public Integer getCode() {
        return code;
    }

    public void setCode(Integer code) {
        this.code = code;
    }

    public String getValue() {
        return value;
    }

    public void setValue(String value) {
        this.value = value;
    }
}
